<?php

namespace App\Admin\Providers;

use App\Admin\Contracts\ActionInterface;
use App\Admin\Contracts\AuthRuleInterface;
use App\Admin\Contracts\ConfigInterface;
use App\Admin\Contracts\MemberInterface;
use App\Admin\Contracts\MenuInterface;
use App\Admin\Repositories\DbActionRepository;
use App\Admin\Repositories\DbAuthRuleRepository;
use App\Admin\Repositories\DbConfigRepository;
use App\Admin\Repositories\DbMemberRepository;
use App\Admin\Repositories\DbMenuRepository;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
    protected $namespace = 'App\Admin\Controllers';
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        require __DIR__.'/../routes.php';
        $this->mapWebRoutes();
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind(AuthRuleInterface::class, DbAuthRuleRepository::class); //授权
        $this->app->bind(MemberInterface::class, DbMemberRepository::class); //用户
        $this->app->bind(MenuInterface::class, DbMenuRepository::class); //后台菜单
        $this->app->bind(ConfigInterface::class, DbConfigRepository::class); //配置
        $this->app->bind(ActionInterface::class, DbActionRepository::class); //活动配置
    }
    /**
     * Define the "web" routes for the application.
     *
     * These routes all receive session state, CSRF protection, etc.
     *
     * @return void
     */
    protected function mapWebRoutes()
    {
        Route::middleware('web')
            ->namespace($this->namespace)
            ->group(__DIR__."/../routes.php");
        //这边可以在分为权限的比方说
//        Route::middleware('permission')
//            ->namespace($this->namespace)
//            ->group(__DIR__."/../auth_routes.php");  //需要权限的路由
    }
}
